package com.own.component.util.locate.config;

import com.own.component.util.locate.base.LocateManager;
import com.own.component.util.locate.base.LocateMapManager;
import com.own.component.util.locate.impl.DefaultHeaderRequestLocateManager;
import com.own.component.util.locate.model.LocateModel;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * DefaultLocateConfig
 *
 * @author chenxueli
 * @date 2023-08-01 10:02:05
 */
@SpringBootConfiguration
public class DefaultLocateConfig {

    @Resource
    private HttpServletRequest request;

    @Bean
    @ConditionalOnMissingBean(value = LocateManager.class)
    public LocateManager locateManager() {
        return new DefaultHeaderRequestLocateManager(request);
    }

    @Bean
    @ConditionalOnMissingBean(value = LocateMapManager.class)
    public LocateMapManager locateMapManager() {
        return keyword -> LocateModel.NONE;
    }

}
